unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    edIn4: TCheckBox;
    edIn5: TCheckBox;
    edIn6: TCheckBox;
    edIn7: TCheckBox;
    Panel2: TPanel;
    UpdateTimer: TTimer;
    Panel1: TPanel;
    pnInput: TPanel;
    Panel4: TPanel;
    pnOutput: TPanel;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    procedure UpdateTimerTimer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    procedure InputRead;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses ParellelIOUnit;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
 Out32(LPT_PORT, StrToInt(Edit1.Text));
end;

procedure TForm1.InputRead;
var
  Data: Byte;
  Data2: Byte;
begin

  Data := 0;
  Data := Inp32(LPT_PORT_IN);
  Data2 := 0;
  Data2 := Inp32(LPT_PORT);

  //Pin13
  if not Boolean(Data and $10) then
    edIn4.Checked := True
  else
    edIn4.Checked := False;
  //Pin12
  if not Boolean(Data and $20) then
    edIn5.Checked := True
  else
    edIn5.Checked := False;
  //Pin10
  if Boolean(Data and $40) then
    edIn6.Checked := False
  else
    edIn6.Checked := True;
  //Pin11 (Hardware Inverted)
  if Boolean(Data and $80) then
    edIn7.Checked := True
  else
    edIn7.Checked := False;

  pnInput.Caption := IntToStr(Data);
  pnOutput.Caption := IntToStr(Data2);

end;

procedure TForm1.UpdateTimerTimer(Sender: TObject);
begin
  InputRead;
end;

end.
